package com.sfac.javaSpringBoot.modules.test.controller;

import com.sfac.javaSpringBoot.aop.MethodCallTimeAnnotation;
import com.sfac.javaSpringBoot.modules.test.entity.Country;
import com.sfac.javaSpringBoot.modules.test.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class CountryController {
    @Autowired
    CountryService countryService;


//    127.0.0.1/api/country/522
    @GetMapping("/country/{countryId}")
    public Country getCountryByCountryId(@PathVariable int countryId) {
        return countryService.getCountryByCountryId(countryId);
    }

//    127.0.0.1/api/country?countryName=China&localCountryName=Zhongguo   --get
//    键值对注解     接收数据
    @GetMapping("/country")
    public Country getCountryByCountryName(@RequestParam String countryName,
                                           @RequestParam String localCountryName){
        return countryService.getCountryByCountryName(countryName,localCountryName);
    }
}
